home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5101 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.4 KB

  1. Path: henon.schap.rhno.columbia.edu!bdl6
  2. From: Bryan D. Lee <bdl6@columbia.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: Converting to ANSI Compliant Macro?
  5. Date: 2 Feb 1996 14:40:03 GMT
  6. Organization: Columbia University
  7. Distribution: world
  8. Message-ID: <4et7o3$or6@lol.cs.columbia.edu>
  9. NNTP-Posting-Host: henon.schap.rhno.columbia.edu
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=ISO-8859-1
  12. Content-Transfer-Encoding: 8bit
  13. X-Newsreader: Nuntius 2.0.4_68K
  14. X-XXMessage-ID: <AD378C6F0C01DE0F@henon.schap.rhno.columbia.edu>
  15. X-XXDate: Fri, 2 Feb 1996 14:39:59 GMT
  16.  
  17. Hi,
  18.  
  19. I have a set of macro's currently being used with AT&T CC (CFront) and
  20. I'm trying to port it to an ANSI-compliant compilier.  Unfortunitaly, I
  21. don't know enough about macros to be able to make the change.  Can anyone
  22. tell me what's wrong with them as they are and how I could either fix
  23. them or rewrite an equilivant macro?
  24.  
  25. enum { BAD_STATUS = -1, GOOD_STATUS = 0 }; 
  26.  
  27. # define PRINT(X) cerr << "( X ) = \"" << (X) << '"' << endl;
  28. # define ASSERT(X) { \
  29.      if(!(X)) { cerr << "ERROR: assertion (X) failed at line " <<
  30. __LINE__ \
  31.              << "." << endl;  return BAD_STATUS; } \
  32. }
  33.  
  34. # define EQ(X,Y) { \
  35.     ostrstream buf; \
  36.     buf << X << ends; \
  37.     if(0 != strcmp(buf.str(), "Y")) { \
  38.         cerr << "ERROR: assertion (" \
  39.          << buf.str() << " == Y) failed at line " << __LINE__ \
  40.              << "." << endl; return -1; \
  41.     } \
  42.     delete buf.str(); \
  43. }
  44.